<template>
<div style="width: 100%">
  <a-card class="card" :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="vertical">
        <a-row :gutter="48">
          <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:6}">
            <a-form-item label="考次">
              <a-select :allowClear="true" v-model="queryParam.sznj">
                <a-select-option v-for="i in TYPE0126" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <template v-if="advanced">
          <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:6}">
            <a-form-item label="开始时间">
              <a-date-picker @change="handleDateChange" />
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:6}">
            <a-form-item label="结束时间">
              <a-date-picker @change="handleDateChange" />
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:6}">
            <a-form-item label="考区">
              <a-select :allowClear="true" v-model="queryParam.sznj">
                <a-select-option v-for="i in TYPE0126" :key="i.id" :value="i.code">{{ i.name }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :sm="{span:12}" :lg="{span:12}" :xl="{span:6}">
            <a-form-item label="备注">
              <a-input placeholder="请输入..." ></a-input>
            </a-form-item>
          </a-col>
          </template>
          <a-col :sm="{span:16}" :lg="{span:8}" :xl="{span:advanced?24:12}">
            <a-button type="primary" @click="loadData">提交</a-button>
            <a @click="advanced = !advanced" style="margin-left: 8px">
                {{ advanced ? '收起' : '展开' }}
                <a-icon :type="advanced ? 'up' : 'down'"/>
              </a>
          </a-col>
        </a-row>
      </a-form>
    </div>
    </a-card>
    <a-card class="card" :bordered="false">
    <a-table
      ref="table"
      size="default"
      rowKey="key"
      :columns="columns"
      :loading="loading"
      :dataSource="data"
      :pagination="false"
    >
      <span slot="serial" slot-scope="text, record, index">
        {{ index + 1 }}
      </span>
    </a-table>
    </a-card>
</div>
</template>

<script>
// import moment from 'moment'
import { STable } from '~'
import { mapState } from 'vuex'

const selectArr = ['TYPE0126', 'TYPE0075', 'TYPE0125', 'TYPE0072']

export default {
  components: {
    STable
  },
  data () {
    return {
      advanced: true,
      loading: false,
      data: [],
      // 查询参数
      queryParam: {
        hzfs: 'yx'
      },
      postParams: {},
      // 表头
      columns: [
        {
          title: '序号',
          scopedSlots: { customRender: 'serial' }
        },
        {
          title: '考场名称',
          dataIndex: 'kcmc'
        },
        {
          title: '位置',
          dataIndex: 'wz'
        },
        {
          title: '最大容量',
          dataIndex: 'zdrl'
        },
        {
          title: '考生数量',
          dataIndex: 'kssl'
        },
        {
          title: '监考老师人数',
          dataIndex: 'jklsrs'
        },
        {
          title: '备注',
          dataIndex: 'bz'
        }
      ],
      selectMenu: {
        yx: [] // 院系
      },
      recruitEditData: {}
    }
  },
  computed: {
    ...mapState({
      systemInfo: state => state.app.systemInfo,
      TYPE0126: state => state.app['TYPE0126'] // 年级
    })
  },
  created () {
    this.initSelectMenu()
    this.loadData()
    selectArr.forEach(v => {
      this.$store.dispatch('app/setDictionary', v)
    })
  },
  methods: {
    initSelectMenu () {
      let allRequest = [
        this.$api.base.collegeAll()
      ]
      Promise.all(allRequest).then(res => {
        this.selectMenu = {
          yx: res[0].data
        }
      })
    },
    // 加载数据
    loadData () {
      return new Promise(resolve => { resolve() }).then(res => {
        this.data = [{
          kcmc: '神奇考场',
          wz: '天国',
          zdrl: '300',
          kssl: '250',
          jklsrs: '10',
          bz: '备注',
          key: 1
        }, {
          kcmc: '神奇考场',
          wz: '天国',
          zdrl: '300',
          kssl: '250',
          jklsrs: '10',
          bz: '备注',
          key: 14
        }, {
          kcmc: '神奇考场',
          wz: '天国',
          zdrl: '300',
          kssl: '250',
          jklsrs: '10',
          bz: '备注',
          key: 13
        } ]
      })
    },
    // 选择招生年度
    zsndChange () {

    },
    // 改变时间
    handleDateChange () {

    }
  }
}
</script>

<style lang="less" scoped>
.card{
  margin-bottom: 20px;
}
</style>
